{% extends 'base.html' %}
{% load staticfiles %}
{% load codalab_tags %}
{% load tz %}

{% block page_title %}Delete Dataset{% endblock page_title %}
{% block head_title %}Delete Dataset{% endblock %}

{% block extra_head %}
{# include extra JS stuff here #}
{% endblock %}

{% block content %}
<form action="" method="post">{% csrf_token %}
    {% if competitions_in_use %}
        <div class="alert alert-warning"><strong>WARNING</strong> DataSet currently in use by:
            <ul class="margin-top">
                {% for competition in competitions_in_use %}
                    <li><a href="{{ competition.get_absolute_url }}">{{ competition }}</a></li>
                {% endfor %}
            </ul>
        </div>
        <p>Are you sure you want to delete "{{ object }}"?</p>
        <div class="checkbox">
            <label for="are-you-sure">
                <input type="checkbox" id="are-you-sure"><strong>Yes</strong>, I am absolutely sure, even though competitions are using this, I want to delete it.
            </label>
        </div>
    {% else %}
        <p>Are you sure you want to delete "{{ object }}"?</p>
    {% endif %}
    <input type="submit" value="Confirm" class="button btn btn-primary disabled confirm-button" disabled/>
    <a href="{% url 'my_datasets' %}" class="button btn btn-default">Cancel</a>
</form>
{% endblock %}

{% block js %}
{% if competitions_in_use %}
    $(".confirm-button").addClass("disabled").attr('disabled','disabled');

    $("#are-you-sure").change(function() {
        if($(this).is(':checked')){
            $(".confirm-button").removeClass("disabled").removeAttr('disabled');
        } else {
            $(".confirm-button").addClass("disabled").attr('disabled','disabled');
        }
    });
{% else %}
    $(".confirm-button").removeClass("disabled").removeAttr('disabled');
{% endif %}
{% endblock js %}
